package com.yanqu.road.server.cmd.strongholdwar.wild;

import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.strongholdwar.CrossStrongholdMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = Protocol.C_CROSS_STRONGHOLD_WILD_DEAL_EVENT,desc = "处理事件")
public class CrossStrongholdWildDealEventCmd extends CrossUnionCommand {
    private int activityId;
    private boolean isDeal;
    private long userId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        StrongholdWarProto.CrossDealStrongholdEventReqMsg req = StrongholdWarProto.CrossDealStrongholdEventReqMsg.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        isDeal = req.getDeal();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        StrongholdWarProto.CrossDealStrongholdEventResp.Builder resp = CrossStrongholdMgr.dealEvent(activityId, serverId, userId, isDeal);
        YanQuMessage msg = YanQuMessageUtils.buildMessage(GameProtocol.S_CROSS_STRONGHOLD_WILD_DEAL_EVENT, resp);
        MessageHelper.sendPacket(serverId,userId,msg);
    }

    @Override
    public void sendData() {

    }
}
